package fr.web325.bean;

import net.sf.json.JSONObject;

public class Json {
    private int code;
    private Object data;
    private String msg;
    private JSONObject respJson;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public JSONObject getRespJson() {
        return respJson;
    }


    /**
     *  @param code HTTP返回状态码
     * @param data 返回 请求所需要的数据
     * @param msg  提示信息
     */
    public Json(int code, Object data, String msg) {
        JSONObject json = new JSONObject();
        json.put("code",code);
        json.put("msg",msg);
        if(data == null){
            this.respJson = json;
        }else{
            json.put("data",data);
            this.respJson = json;
        }
        this.code = code;
        this.data = data;
        this.msg = msg;
    }

    public Json() {
    }
}
